public class Exercise4 {
    public int maxProfit(int[] prices) {
        int low = Integer.MAX_VALUE;
        int max = 0;
        for (int price : prices) {
            low = Math.min(price,low);
            max = Math.max(max,price-low);
        }
        return max;
    }
}
